<template>
	<view class="more-service-item-container">
		<!-- 图片 -->
		<view class="more-service-item-image">
			<lazy-image :src="$img_base_url(addGoods.image)"></lazy-image>
		</view>
		<view class="more-service-item-content">
			<view class="title">
				<text>{{addGoods.name}}</text>
			</view>
			<view class="display-flex alig mt-20">
				<view class="price">
					<text><text style="font-size: 26rpx;">¥</text>{{addGoods.price}}</text>
				</view>
				<view class="old-price">
					<text>¥{{addGoods.market_price}}</text>
				</view>
			</view>
			<view class="display-flex alig center margin-top-10">
				<view class="goods-sku-item-num-input">
					<view class="num-icon">
						<image :src="$img_path('/home/detail/num-del.png')" @click="reduce" mode="widthFix"></image>
					</view>
					<view class="num-input">
						<text>{{number}}</text>
					</view>
					<view class="num-icon">
						<image :src="$img_path('/home/detail/num-add.png')" @click="add" mode="widthFix"></image>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		props:{
			addGoods:{
				type:Object,
				default:{}
			},
		},
		data(){
			return {
				number:0
			}
		},
		methods:{
			reduce(){
				if(this.number>0){
					this.number--
				}
				this.$emit('selectAddGoods',this.addGoods.id,this.number)
			},
			add(){
				if(this.number<1){
					this.number++
					this.$emit('selectAddGoods',this.addGoods.id,this.number)
				}else{
					uni.showToast({
						title:'只能添加一个哦',
						icon:'none'
					})
				}
			}
		}
	}
</script>

<style scoped lang="scss">
	.more-service-item-container {
		width: 278rpx;
		height: 444rpx;
		background: #FFFFFF;
		box-shadow: 0rpx 0rpx 24rpx 2rpx rgba(0,0,0,0.05);
		border-radius: 20rpx;
		overflow: hidden;
	}
	
	.more-service-item-image {
		width: 278rpx;
		height: 246rpx;
		border-radius: 20rpx 20rpx 0 0;
	}
	
	.more-service-item-content {
		padding: 10rpx;
		font-weight: bold;
		font-size: 28rpx;
		color: #333333;
	}
	
	.price {
		font-weight: 900;
		font-size: 36rpx;
		color: #FF2E2E;
	}
	
	.old-price {
		font-weight: 400;
		font-size: 24rpx;
		color: #999999;
		text-decoration: line-through;
		margin-left: 5rpx;
	}
	
	.goods-sku-item-num-input {
		display: flex;
		align-items: center;
	}
	
	.num-icon {
		width: 44.8rpx;
		height: 44.8rpx;
	}
	
	.num-input {
		width: 50rpx;
		font-weight: 400;
		font-size: 38rpx;
		color: #666666;
		text-align: center;
	}
</style>